import pymysql

con = pymysql.connect(
    host='localhost',
    user='root',
    password='123456',
    port=3306,
    database='db_qiku'
)

cursor = con.cursor()

# sql语句创建表
sql = 'drop table if exists tb_book;'

cursor.execute(sql)

sql = """
    create table tb_book(id int primary key not null auto_increment,
    bookname varchar(20) not null,putdate date);

"""

cursor.execute(sql)

# 展示所有表
sql = 'show tables'
cursor.execute(sql)
tables = cursor.fetchall()
print(tables)

cursor.close()
con.close()
